<?php
namespace Api\Controller;

use Qcloud\Cos\Client;
use Think\Controller;
use Think\Exception;
use Think\Log;

require_once('plugins/cos-autoloader.php');

class UController extends Controller
{
    public function uploadPhoto()
    {
        $cosClient = new Client(array('region' => getenv('COS_REGION'),
            'credentials' => array(
                'appId' => getenv('COS_APPID'),
                'secretId' => getenv('COS_KEY'),
                'secretKey' => getenv('COS_SECRET'))));

#putObject
        try {
            $result = $cosClient->putObject(array(
                'Bucket' => 'testbucket-1252448703',
                'Key' => '11//32//43',
                'Body' => 'Hello World!',
                'ServerSideEncryption' => 'AES256'));
            print_r($result);
        } catch (\Exception $e) {
            echo "$e\n";
        }
    }


}
